000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. FSLOGGER.
       AUTHOR. GROEP 28.
       AUTHOR. MICHEL GRYP.
       AUTHOR. MICHAEL HEUGHEBAERT.
       AUTHOR. MATTHIAS REYNAERT.
       
       ENVIRONMENT DIVISION.
              
       DATA DIVISION.
       LINKAGE SECTION.
       COPY LOGHELPERCOPY.
       COPY FSCOPY.
       
       PROCEDURE DIVISION USING LOGLINE, FILE-STATUS.
       PGM.
       
       EVALUATE STATUS-KEY-1 
         WHEN "0" 
           CONTINUE
         WHEN "1" 
           MOVE "End of file reached*" TO LOGMESSAGE
           PERFORM LOGGER
           PERFORM END-OF-FILE
         WHEN "2" 
           MOVE "Invalid Key*" TO LOGMESSAGE 
           PERFORM LOGGER
           PERFORM INVALID-KEY 
         WHEN "3" 
           MOVE "Permanent Error*"  TO LOGMESSAGE 
           PERFORM LOGGER
           PERFORM PERMANENT-ERROR 
         WHEN "4" 
           MOVE "Logic Error*"  TO LOGMESSAGE
           PERFORM LOGGER
         WHEN "9" 
           MOVE "Runtime system error*" TO LOGMESSAGE
           PERFORM LOGGER
           PERFORM RUNTIME-ERROR
       END-EVALUATE
       
       EXIT PROGRAM.
       
       END-OF-FILE.
       IF STATUS-KEY-2 = "0" 
         MOVE "No next logical record*"  TO LOGMESSAGE
         PERFORM LOGGER
       END-IF
       
       INVALID-KEY.
       EVALUATE STATUS-KEY-2 
         WHEN "2" 
           MOVE "Attempt to write duplicate key*" TO LOGMESSAGE
         WHEN "3" 
           MOVE "No record found*" TO LOGMESSAGE
       END-EVALUATE
       
       PERFORM LOGGER
       
       PERMANENT-ERROR.
       IF STATUS-KEY-2  = "5" 
         MOVE "File not found*" TO LOGMESSAGE
         PERFORM LOGGER
       END-IF
       
       RUNTIME-ERROR.
       EVALUATE BINARY-STATUS
         WHEN 002
           MOVE "File not open*" TO LOGMESSAGE
         WHEN 007
           MOVE "Disk space exhausted*" TO LOGMESSAGE
         WHEN 013
           MOVE "File not found*" TO LOGMESSAGE
         WHEN 024
           MOVE "Disk error*" TO LOGMESSAGE
         WHEN 065
           MOVE "File locked*" TO LOGMESSAGE
         WHEN 068
           MOVE "Record locked*" TO LOGMESSAGE
         WHEN 039
           MOVE "Record inconsistent*" TO LOGMESSAGE
         WHEN 146
           MOVE "No current record*" TO LOGMESSAGE
         WHEN 180
           MOVE "File malformed*" TO LOGMESSAGE
         WHEN 208
           MOVE "Network error*" TO LOGMESSAGE
         WHEN 213
           MOVE "Too many locks*" TO LOGMESSAGE
         WHEN OTHER
           MOVE "Not an error status*" TO LOGMESSAGE
       END-EVALUATE
       
       PERFORM LOGGER
       
       LOGGER.
       CALL "Logger" USING LOGLINE END-CALL